home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part2 / 11050 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.3 KB

  1. Path: nebula.broadvision.com!usenet
  2. From: patrick@broadvision.com (Patrick Horgan)
  3. Newsgroups: comp.sources.wanted,comp.lang.c,comp.unix.programmer
  4. Subject: Re: Seek unix2dos.c OR help with tr
  5. Date: 21 Mar 1996 17:24:19 GMT
  6. Organization: The quite unorganized Patrick
  7. Message-ID: <4is3c3$jmp@ns.broadvision.com>
  8. References: <danpop.826917054@rscernix>
  9. Reply-To: patrick@broadvision.com
  10. NNTP-Posting-Host: star.broadvision.com
  11.  
  12. In article <danpop.826917054@rscernix>, danpop@mail.cern.ch (Dan Pop) writes:
  13. >Moreover, 0x1f is not a magic number _in this context_ any more than 2
  14. >is a magic number in a binary search algorithm or 3.1415926 is a magic
  15. >number when computing the circumference of a circle.  All of them are
  16. >natural constants
  17.  
  18. I agree...and it's the way I would do it as well.
  19.  
  20. >
  21. >As for Kazimir's example, a "better" definition would be:
  22. >
  23. >#define CTRL(C) ((C) - 'A' + 1)
  24.  
  25. If I went down this path I'd choose ((C) - '@' )...somehow the + 1 seems as if it
  26. will lead to further silly misunderstandings by junior programmers...I much prefer
  27. anding off the upper bits though...anding with 0x3f is better and even works for 
  28. characters generated on some keyboards whose code is over 127...the subtraction
  29. method won't.
  30.  
  31. -- 
  32.  
  33.    Patrick J. Horgan    patrick@broadvision.com   Have horse will ride.
  34.    Opinions mine, not my employer's except by most bizarre coincidence.
  35.  
  36.  
  37.